EntityList = class(List)
EntityList.RenderDistance = 3000

function EntityList:init()
    List.init(self)
    self.t = Tesselator()
end

function EntityList:tick()
    pos = player:getPos()
    for i,v in ipairs(self.list) do
        if v.removed then
            self:remove(i)
        elseif v:distanceToSqr(pos) < EntityList.RenderDistance then
            v:tick()
        end
    end
end

function EntityList:render(frustum,a)
    local t = self.t
    t:begin()
    t:bindTex(Tex)
    local pos = player:getPos()
    for i,v in ipairs(self.list) do
        if v.render and frustum:isVisible(v.aabb) and v:distanceToSqr(pos) < EntityList.RenderDistance then
            v:render(a,t)
        end
    end
    t:End()
    t:render()
end